package com.m7788.util;

import android.app.DownloadManager;
import android.content.Context;
import android.net.Uri;

/**
 * Created by gxchen on 2018/7/13.
 */

public class DownFileUtil {
    public void downFile(Context context,final String webUrl, final String dirPath,
                         final String fileName){
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(webUrl));
        //指定下载路径和下载文件名
        request.setDestinationInExternalPublicDir(dirPath, fileName);
        //获取下载管理器
        DownloadManager downloadManager= (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
        //将下载任务加入下载队列，否则不会进行下载
        downloadManager.enqueue(request);
    }
}
